const log4js = require('log4js')
const path = require('path')

log4js.configure({
    appenders: {
        resLogger: {
            type: 'dateFile',
            filename: path.join('./logs/', '/Log', 'bot-'),
            pattern: 'yyyyMMdd.log',
            alwaysIncludePattern: true,
            backups: 7
        },
        error: {
            type: 'dateFile',
            filename: path.join('./logs', '/errLog', 'botError-'),
            pattern: 'yyyyMMdd.log',
            alwaysIncludePattern: true,
            backups: 7
        },
        errorLogger: {
            type: 'logLevelFilter',
            appender: 'error',
            level: 'error'
        }
    },
    categories: {
        default: {
            appenders: ['resLogger', 'errorLogger'],
            level: 'info'
        }
    },
})


const resLogger = log4js.getLogger('resLogger')
const errorLogger = log4js.getLogger('errorLogger')

exports.Log = function(msg){
    resLogger.info(msg);
}

exports.Error = function(msg){
    errorLogger.error(msg);
}